<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>后台用户权限管理</title>
 <%@include file="/WEB-INF/base.jspf"%>
  <style type="text/css">
  	.body_wrapper{
  		height: 100%;
  		width: 100%;
  		box-sizing: border-box;
  		padding: 0px 20px;
  		
  		
  	}
  		.modal-dialog {
		max-width: 1000px;
	}
  	.wrapper_buttons{
  		margin-left: 50px;
  		margin-bottom: 20px;
  		margin-top: 20px;
  		position: relative;
  	}
  	.shezhileiContent{
  		width: 160px;
  		height: 150px;
  		border: 1px solid  #9c8f8f;
  		border-radius: 5px;
  		box-sizing: border-box;
  		padding: 13px;
  		position: absolute;
  		right: 0px;
  		top: 36px;
  		z-index: 999;
  		background: #fff;
  		
  		
  	}
  	.shezhileiContent li {
  		margin-bottom:10px ;
  	}
  	.shezhileiContent li span{
  		margin-left: 6px;
  	}
  	.content_neirong p{
  		display: flex;
  		align-items: center;
  		height: 20px;
  		line-height: 20px;
  	}
  	.content_neirong span{
  		margin-left: 13px;
  	}
  	.content_neirong input{
  		margin-bottom: 4px;
  	}
 	table th,table tr,table td {
	text-align: center;
	vertical-align:middle;
	}
  </style>
</head>
<body>
	<div class="body_wrapper">
		<table id="table_id_example" class="class-tableDataTable class-table-needClick display table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th>用户序号</th>
							<th>用户昵称</th>
							<th>用户帐号</th>
							<th>用户类型</th>
							<th>用户IP</th>
							<th>操作</th>
							<th style="display:none;"></th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${user}" var="emp" varStatus="statu">
						  <tr class="">
							<td>${statu.index + 1}</td>
							<td class="td-c-nick_name">${emp.nick_name}</td>
							<td class="td-c-userName">${emp.name}</td>
							<td class="td-c-admin_type">
							<c:if test="${emp.admin_type==0}"> 管理员</c:if>
							<c:if test="${emp.admin_type==4}"> 超级管理员</c:if>
							<c:if test="${emp.admin_type==1}"> 充值提现客服</c:if>
							<c:if test="${emp.admin_type==2}"> 游戏优惠客服</c:if>
							<c:if test="${emp.admin_type==3}"> 修改信息客服</c:if>
							</td>
							<td>${emp.ip}</td>
							<td>
								<button class="btn btn-default quanxianshezhi-c-btn">权限设置</button>
							</td>
							<td class="td-c-quanxianStr" style="display:none;">${emp.name}</td>						
						</tr>
						</c:forEach>
					</tbody>
				</table>
	</div>
 
<!---------------------------新增模态框开始------------------------------------->
 
					<div class="modal fade" id="addAndEditModal"
						tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
						aria-hidden="true">
						<div class="modal-dialog" style="width: 400px;">
							<div class="modal-content">
								<div class="modal-header" style="height: 10px;">
									<span id="" style="float: left; margin-top: -10px;">
										添加组别</span>
									<button type="button" class="close" data-dismiss="modal"
										aria-hidden="true" style="margin-top: -10px;">&times;</button>

								</div>
							<form  method="post" id="">
								<div class="modal-body"
									style="box-sizing: border-box; padding: 0px 40px;">
									<input hidden="hidden" name="id" id="id-edit-id" />
									<div style="display: flex; flex-direction: row; align-items: center; margin:20px 0px; justify-content: space-between;">
											<div
												style="display: flex; flex-direction: row; align-items: center; margin-right: 5px;">
												<div style="font-size: 16px;">
													组别名称 <span style="color: #FF0000;"></span>&nbsp;
												</div>
												<input type="dtext" placeholder="" name="time" id="id-edit-time"
													style="width: 200px; height: 30px;"/>
											</div>
											
										</div>
								</div>
								<div class="modal-footer">
									<button type="button" class="btn btn-default"
										data-dismiss="modal" style="background: orangered;">关闭</button>
								</div>
							</form>
							</div>
							<!-- /.modal-content -->
						</div>
						<!-- /.modal -->
					</div>
<!---------------------------修改模态框开始------------------------------------->
 
					<div class="modal fade" id="editModal"
						tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
						aria-hidden="true">
						<div class="modal-dialog" style="width: 400px;">
							<div class="modal-content">
								<div class="modal-header" style="height: 10px;">
									<span id="" style="float: left; margin-top: -10px;">
										添加组别</span>
									<button type="button" class="close" data-dismiss="modal"
										aria-hidden="true" style="margin-top: -10px;">&times;</button>

								</div>
							<form  method="post" id="">
								<div class="modal-body"
									style="box-sizing: border-box; padding: 0px 40px;">
									<input hidden="hidden" name="id" id="id-edit-id" />
									<div style="display: flex; flex-direction: row; align-items: center; margin:20px 0px; justify-content: space-between;">
											<div
												style="display: flex; flex-direction: row; align-items: center; margin-right: 5px;">
												<div style="font-size: 16px;">
													组别名称 <span style="color: #FF0000;"></span>&nbsp;
												</div>
												<input type="dtext" placeholder="" name="time" id="id-edit-time"
													style="width: 200px; height: 30px;"/>
											</div>
											
										</div>
								</div>
								<div class="modal-footer">
									<input type="submit" class="btn btn-primary" value="保存"
										 style="background: darkcyan;" id=""/>
									<button type="button" class="btn btn-default"
										data-dismiss="modal" style="background: orangered;">关闭</button>
								</div>
							</form>
							</div>
							<!-- /.modal-content -->
						</div>
						<!-- /.modal -->
					</div>
					
					<!---------------------------权限设置模态框开始------------------------------------->
 
					<div class="modal fade" id="shezhiquanxianModal"
						tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
						aria-hidden="true">
						<div class="modal-dialog" style="width: 900px;">
							<div class="modal-content">
								<div class="modal-header" style="height: 10px;">
									<span id="" style="float: left; margin-top: -10px;">
										添加组别</span>
									<button type="button" class="close" data-dismiss="modal"
										aria-hidden="true" style="margin-top: -10px;">&times;</button>

								</div>
								<!-- cwgl -->
							<form action="/kajhsgweasdqtwehghasfdnsak6868/updateUserJurisdiction.do" method="post" id="id-addAndEditModal-form">
							<input name="name" id="input-i-id" hidden value="" />
							<input name="cwgl" id="input-i-allIds" hidden value="" />
								<div class="modal-body" style="box-sizing: border-box; padding: 0px 0px;">
									<div class="modal-boay_content" style="height: 500px;width: 100%;overflow-y: auto;padding:10px 15px;">
										<div class="content_neirong" style="min-height: 1000px;width: 100%;border: 1px solid #d4cece;">
											<p><input type="checkbox" class="input-i-subCheck" name="" id="" value="1" /><span>财务管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="2" /><span>用户充值管理</span></p>
												<p><input type="checkbox" name="" id="" value="3" /><span>用户提款管理</span></p>
												<p><input type="checkbox" name="" id="" value="4" /><span>用户金额管理</span></p>
												<p><input type="checkbox" name="" id="" value="5" /><span>用户账变管理</span></p>
												<p><input type="checkbox" name="" id="" value="6" /><span>用户打码管理</span></p>
												<p><input type="checkbox" name="" id="" value="7" /><span>用户打码记录</span></p>
												<p><input type="checkbox" name="" id="" value="8" /><span>日常返水管理</span></p>
											</div>
											<p><input type="checkbox" class="input-i-subCheck" name="" id="" value="9" /><span>彩票管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="10" /><span>彩票投注管理</span></p>
												<p><input type="checkbox" name="" id="" value="11" /><span>彩票开奖管理</span></p>
												<p><input type="checkbox" name="" id="" value="12" /><span>私彩预设管理</span></p>
												<p><input type="checkbox" name="" id="" value="13" /><span>港彩预设管理</span></p>
												<p><input type="checkbox" name="" id="" value="14" /><span>港彩属性管理</span></p>
												<p><input type="checkbox" name="" id="" value="15" /><span>特码反水管理</span></p>
												<p><input type="checkbox" name="" id="" value="16" /><span>彩票开启管理</span></p>
												<p><input type="checkbox" name="" id="" value="17" /><span>彩票赔率管理</span></p>
												<p><input type="checkbox" name="" id="" value="18" /><span>彩票球数管理</span></p>
												<p><input type="checkbox" name="" id="" value="19" /><span>百家乐管理</span></p>
											</div>
											<p><input type="checkbox" class="input-i-subCheck" name="" id="" value="20" /><span>用户管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="21" /><span>平台用户管理</span></p>
											 	<p><input type="checkbox" name="" id="" value="22" /><span>平台代理管理</span></p>
												<p><input type="checkbox" name="" id="" value="23" /><span>代理返点记录</span></p>
												<p><input type="checkbox" name="" id="" value="24" /><span>代理返点管理</span></p>
												<p><input type="checkbox" name="" id="" value="25" /><span>代理说明管理</span></p>
												<p><input type="checkbox" name="" id="" value="26" /><span>用户聊天管理</span></p>
												<p><input type="checkbox" name="" id="" value="27" /><span>聊天屏蔽管理</span></p>
												<p><input type="checkbox" name="" id="" value="28" /><span>系统红包管理</span></p>
											</div>
											
											<p><input type="checkbox" class="input-i-subCheck" name="" id="" value="29" /><span>报表管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="30" /><span>全局报表管理</span></p>
												<p><input type="checkbox" name="" id="" value="31" /><span>财务报表管理</span></p>
												<p><input type="checkbox" name="" id="" value="32" /><span>统计概况管理</span></p>
												<p><input type="checkbox" name="" id="" value="33" /><span>运营报表管理</span></p>
												<p><input type="checkbox" name="" id="" value="34" /><span>风险评估管理</span></p>
												<p><input type="checkbox" name="" id="" value="35" /><span>用户概况管理</span></p>
											</div>
											<p><input type="checkbox" class="input-i-subCheck" name="" id="" value="36" /><span>公告管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="37" /><span>首页公告管理</span></p>
												<p><input type="checkbox" name="" id="" value="38" /><span>用户通知管理</span></p>
												<p><input type="checkbox" name="" id="" value="39" /><span>轮播发布管理</span></p>
											</div>
											<p><input type="checkbox" class="input-i-subCheck" name="" id="" value="40" /><span>活动管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="41" /><span>优惠活动管理</span></p>
												<p><input type="checkbox" name="" id="" value="42" /><span>幸运抽奖设置</span></p>
											</div>
											<p><input type="checkbox" class="input-i-subCheck" name="" id="" value="43" /><span>客服管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="44" /><span>在线客服管理</span></p>
												<p><input type="checkbox" name="" id="" value="45" /><span>QQ客服管理</span></p>
												<p><input type="checkbox" name="" id="" value="46" /><span>客服聊天系统</span></p>
												<p><input type="checkbox" name="" id="" value="47" /><span>自动回复管理</span></p>
												<p><input type="checkbox" name="" id="" value="48" /><span>快捷回复管理</span></p>
											</div>											
											<p><input type="checkbox" class="input-i-subCheck" name="" id="" value="49" /><span>系统管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="50" /><span>平台基本管理</span></p>
												<p><input type="checkbox" name="" id="" value="51" /><span>在线入款管理</span></p>
												<p><input type="checkbox" name="" id="" value="52" /><span>入款银行管理</span></p>
												<p><input type="checkbox" name="" id="" value="53" /><span>扫码支付管理</span></p>
												<p><input type="checkbox" name="" id="" value="54" /><span>推广链接管理</span></p>
												<p><input type="checkbox" name="" id="" value="55" /><span>绑定域名管理</span></p>
												<p><input type="checkbox" name="" id="" value="56" /><span>下载页面管理</span></p>
												<p><input type="checkbox" name="" id="" value="57" /><span>平台说明管理</span></p>
												<p><input type="checkbox" name="" id="" value="58" /><span>页面更新管理</span></p>
												<p><input type="checkbox" name="" id="" value="59" /><span>总代理用户管理</span></p>
												<p><input type="checkbox" name="" id="" value="65" /><span>白名单用户管理</span></p>
											</div>
											<p><input type="checkbox" name="" class="input-i-subCheck" id="" value="60" /><span>后台管理</span></p>
											<div class="div-c-subItem" style="margin-left:87px ;">
												<p><input type="checkbox" name="" id="" value="61" /><span>后台用户管理</span></p>
												<p><input type="checkbox" name="" id="" value="62" /><span>用户权限管理</span></p>
 												<p><input type="checkbox" name="" id="" value="63" /><span>登录日志管理</span></p>
												<p><input type="checkbox" name="" id="" value="64" /><span>操作日志管理</span></p>
											</div>
										</div>
									</div>
								</div>
								<div class="modal-footer">
									<button type="button" class="btn btn-primary"
										 style="background: darkcyan;" id="id-input-addAndEditAJAXBtn">保存</button>
									<button type="button" class="btn btn-default"
										data-dismiss="modal" style="background: orangered;">关闭</button>
								</div>
							</form>
							</div>
						</div>
					</div>
<div class="modal fade" id="noticeModal" tabindex="-1" role="dialog" aria-labelledby="noticeModal" aria-hidden="true" style="z-index:1051;">
    <div class="modal-dialog class-fake-alert">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body" ></div>
            <div class="modal-footer">	      
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>  

<!-- 删除模态框（Modal）结束 -->  
<script>
//由于模块都一次性加载，因此不用执行 layui.use() 来加载对应模块，直接使用即可：
;!function(){
  var layer = layui.layer
  ,form = layui.form;
  
  /*layer.msg('Hello World');*/
}();

function  dataTable01(){
			$("#table_id_example").DataTable({
		      // "bPaginate": true,
		      "bLengthChange": true,      
		      "bSort": false,
		      // "bInfo": true,
		      "bAutoWidth": false,
//		         "bServerSide":true,
		      'aLengthMenu':[5, 10, 20],
		       "searching": true, 
		       "dom": "t<'tableinfo'i<'tableSearch'p>l>",
//		    "searching": true,l
		       "language": {//语言设置  
		            "lengthMenu": "每页显示 _MENU_ 条记录",     
		            "zeroRecords": "没有检索到数据",     
		            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
		            "info": "没有数据",     
		            "oPaginate": {     
		                "sFirst": "首页",     
		                "sPrevious": "前一页",     
		                "sNext": "后一页",     
		                "sLast": "尾页"    
		          	},
		            "search":"",
		            "searchPlaceholder": "请输入关键字",
		            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
		            "infoEmpty":      "没有找到匹配的信息",
		         }
		                 
		                 
		    })
		}
		 dataTable01();
		 insertSearchBtn()
			/*
			function shuaxinButton(){//刷新按钮事件
				$('#classify_right_refresh').click(function() {
					var iframeElement = window.parent.document.querySelector("#testFrame")
		    		iframeElement.src = "/huishen/sbgl/keepUpPlan.do"
				})
			}*/
			
			function shezhileixianshiyincang(){//设置列的显示与隐藏
				 $('.sheizhilie').click(function(){ 
				    if($('.shezhileiContent').is(':hidden')){ 
				    	$('.shezhileiContent').show();
				    
				    }else{
				    	$('.shezhileiContent').hide();
				    } 
				    event.stopPropagation();
				})  
				$('.shezhileiContent').click(function(){ 
				    event.stopPropagation();
				})
				$('body').click(function(){$(".shezhileiContent").hide();});
			}
			shezhileixianshiyincang()
			$(".input-i-subCheck").on("change", function(event) {
				var $Item = $(event.currentTarget)
				var $NextDiv = $Item.parent().next()
				$NextDiv.find("input[type='checkbox']").prop("checked", $Item.prop("checked"))
				//$Item
			})
			$(".div-c-subItem input[type='checkbox']").on("change", function(event) {
				var $Item = $(event.currentTarget)
				var $Parent = $Item.closest(".div-c-subItem")
				var $ParentInputBox = $Parent.prev().find("input[type='checkbox']")
				if (!$Item.prop("checked")) {
					$ParentInputBox.prop("checked", false)
				} else {
					var flag = true
					$Parent.find("input[type='checkbox']").each(function(index, element) {
						if(!element.checked) {
							flag = false
						}
					})
					$ParentInputBox.prop("checked", flag)
				}
			})
			$(".quanxianshezhi-c-btn").on("click", function(event) {
				var userName = event.currentTarget.closest("tr").querySelector(".td-c-userName").textContent
				$("#input-i-id").val(userName)
				var urlPath = "/kajhsgweasdqtwehghasfdnsak6868/findUserJurisdiction.do"
				var newRequest = {
					url: urlPath,
					type: "post",
					data: 
						{
							"name": userName,
						},
					success: function(data) {
						var newData = JSON.parse(data)
						if (newData.data != null) {
							var quanxianArray = newData.data.cwgl.split(",")
							$(".content_neirong input[type='checkbox']").each(function(index, element) {
								if (quanxianArray.includes(element.value)) {
									element.checked = true
								}
							})							
						}
						setQuanXianCheckBoxValue()
						$("#shezhiquanxianModal").modal("show")
					},
					error: function(status) {
						console.log("status", status)
					}
				}
				ajax(newRequest)					
			})
			
			var setQuanXianCheckBoxValue = function() {
				var result = ""
				$(".content_neirong input[type='checkbox']").each(function(index, element) {
					//input-i-allIds
					if (element.checked) {
						var newValue = element.value + ","
						result += newValue
					}
				})
				$("#input-i-allIds").val(result.slice(0, result.length - 1))				
			}
			
			$("#id-input-addAndEditAJAXBtn").on("click", function(event) {
				setQuanXianCheckBoxValue()
				$("#id-addAndEditModal-form").submit()
			})
	</script> 
</body>
</html>